home *** CD-ROM | disk | FTP | other *** search
/ Professional Soft Collection 1.02 / Professional Soft Collection 1.02.iso / communic / qmodempr / script.pak / HOSTFILE.SCR < prev    next >
Encoding:
Text File  |  1994-03-01  |  5.9 KB  |  209 lines

  1. ' File area routines for host mode.
  2.  
  3. function GetProtocol as integer
  4.   dim s as string
  5.   if not DisplayFile(ProtocolFileName) then
  6.     send #Port, "Select a file transfer protocol:"
  7.     send #Port,
  8.     send #Port, "[A] Ascii  [X] Xmodem   [C] Xmodem/CRC  [1] Xmodem/1K  [F] Xmodem/1KG"
  9.     send #Port, "[Y] Ymodem [G] Ymodem/G [Z] Zmodem      [K] Kermit"
  10.   end if
  11.   send #Port,
  12.   s = GetLine("Protocol: ")
  13.   select case OemUpper(left(s, 1))
  14.     case "A"
  15.       GetProtocol = ASCII
  16.     case "X"
  17.       GetProtocol = Xmodem
  18.     case "C"
  19.       GetProtocol = XmodemCRC
  20.     case "1"
  21.       GetProtocol = Xmodem1K
  22.     case "F"
  23.       GetProtocol = Xmodem1KG
  24.     case "Y"
  25.       GetProtocol = Ymodem
  26.     case "G"
  27.       GetProtocol = YmodemG
  28.     case "Z"
  29.       GetProtocol = Zmodem
  30.     case "K"
  31.       GetProtocol = Kermit
  32.   end select
  33. end function
  34.  
  35. function ProtocolName(prot as integer) as string
  36.   select case prot
  37.     case ASCII
  38.       ProtocolName = "ASCII"
  39.     case Xmodem
  40.       ProtocolName = "Xmodem"
  41.     case XmodemCRC
  42.       ProtocolName = "Xmodem/CRC"
  43.     case Xmodem1K
  44.       ProtocolName = "Xmodem/1K"
  45.     case Xmodem1KG
  46.       ProtocolName = "Xmodem/1KG"
  47.     case Ymodem
  48.       ProtocolName = "Ymodem"
  49.     case YmodemG
  50.       ProtocolName = "Ymodem/G"
  51.     case Zmodem
  52.       ProtocolName = "Zmodem"
  53.     case Kermit
  54.       ProtocolName = "Kermit"
  55.   end select
  56. end function
  57.  
  58. ' List files
  59.  
  60. sub ListFiles
  61.   dim result as integer, count as integer, total as integer, sr as SearchRec
  62.   if Setup.dlpath = "" then
  63.     send #Port,
  64.     send #Port, "Sorry, downloads are not available."
  65.     send #Port,
  66.     exit sub
  67.   end if
  68.   total = 0
  69.   count = 0
  70.   result = FindFirst(AddBackSlash(Setup.dlpath)+"*.*", 0, sr)
  71.   do while result = 0 and not CallerHungUp
  72.     dim i as integer
  73.     i = instr(sr.name, ".")
  74.     if i > 0 then
  75.       send #Port, left(sr.name, i-1); tab(10); right(sr.name, len(sr.name)-i); tab(14);
  76.     else
  77.       send #Port, sr.name; tab(14);
  78.     end if
  79.     send #Port, space(11-len(str(sr.size))); sr.size;
  80.     send #Port, DateToDateString(" mm-dd-yy", DMYtoDate(sr.date and 0x1f, (sr.date\32) and 0xf, 1980+(sr.date\512)));
  81.     send #Port, TimeToTimeString(" HH:mmt", HMStoTime(sr.time\2048, (sr.time\32) and 0x3f, (sr.time and 0x1f) * 2));
  82.     send #Port,
  83.     total = total + 1
  84.     count = count + 1
  85.     if count >= 24 then
  86.       if OemUpper(GetLine("-Pause- [C]ontinue, [S]top? ", 1)) = "S" then
  87.         exit do
  88.       end if
  89.       count = 0
  90.     end if
  91.     result = FindNext(sr)
  92.   loop
  93.   send #Port,
  94.   send #Port, total; " file(s) available"
  95.   send #Port,
  96.   GetLine "Press Enter to continue? "
  97. end sub
  98.  
  99. ' Download file
  100.  
  101. sub DownloadFile
  102.   dim fnames as string, protocol as integer, count as integer
  103.   dim onefile as integer
  104.   if Setup.dlpath = "" then
  105.     send #Port,
  106.     send #Port, "Sorry, downloads are not available."
  107.     send #Port,
  108.     exit sub
  109.   end if
  110.   protocol = GetProtocol()
  111.   if protocol = 0 then exit sub
  112.   onefile = protocol < Ymodem
  113.   do
  114.     dim s as string
  115.     s = GetLine("File to download: ")
  116.     if CallerHungUp then
  117.       exit sub
  118.     end if
  119.     if s = "" then exit do
  120.     send #Port,
  121.     if Setup.sysopanypath = 0 or User.Level = 0 then
  122.       s = AddBackSlash(Setup.dlpath)+JustFilename(s)
  123.       print "not sysop"
  124.     elseif instr(s, "\") = 0 then
  125.       s = AddBackSlash(Setup.dlpath)+JustFilename(s)
  126.       print "no backslash"
  127.     end if
  128.     dim sr as SearchRec
  129.     if findfirst(s, 0, sr) = 0 then
  130.       do
  131.         if len(fnames) > 0 then
  132.           fnames = fnames + " "
  133.         end if
  134.         fnames = fnames + AddBackSlash(JustPathName(s)) + sr.Name
  135.         count = count + 1
  136.         dim i as integer
  137.         i = instr(sr.name, ".")
  138.         if i > 0 then
  139.           send #Port, left(sr.name, i-1); tab(10); right(sr.name, len(sr.name)-i); tab(14);
  140.         else
  141.           send #Port, sr.name; tab(14);
  142.         end if
  143.         send #Port, space(11-len(str(sr.size))); sr.size;
  144.         send #Port, DateToDateString(" mm-dd-yy", DMYtoDate(sr.date and 0x1f, (sr.date\32) and 0xf, 1980+(sr.date\512)));
  145.         send #Port, TimeToTimeString(" HH:mmt", HMStoTime(sr.time\2048, (sr.time\32) and 0x3f, (sr.time and 0x1f) * 2));
  146.         send #Port,
  147.       loop until (onefile and count = 1) or findnext(sr) <> 0
  148.       send #Port,
  149.     else
  150.       send #Port, "The file "; s; " could not be found on disk."
  151.     end if
  152.   loop until onefile and count = 1
  153.   if count > 0 then
  154.     if Local then
  155.       send #Port, "The following files would be transferred if you were not on locally:"
  156.       send #Port, fnames
  157.     else
  158.       send #Port,
  159.       send #Port, "Begin your "; ProtocolName(protocol); " download of ";
  160.       if count = 1 then
  161.         send #Port, fnames;
  162.       else
  163.         send #Port, count, " files"
  164.       end if
  165.       send #Port, " now"
  166.       delay 1
  167.       sendfile fnames, protocol
  168.     end if
  169.   else
  170.     send #Port, "No files selected."
  171.   end if
  172. end sub
  173.  
  174. ' Upload file
  175.  
  176. sub UploadFile
  177.   dim fname as string, protocol as integer
  178.   if Setup.ulpath = "" then
  179.     send #Port,
  180.     send #Port, "Sorry, uploads are not available."
  181.     send #Port,
  182.     exit sub
  183.   end if
  184.   if Local then
  185.     send #Port, "Uploads not available when logged on locally"
  186.     exit sub
  187.   end if
  188.   protocol = GetProtocol()
  189.   if protocol = 0 or CallerHungUp then exit sub
  190.   send #Port,
  191.   fname = "your file"
  192.   if protocol < Ymodem then
  193.     fname = GetLine("File to upload: ")
  194.     send #Port,
  195.     if fname = "" or CallerHungUp then exit sub
  196.     fname = AddBackSlash(Setup.ulpath)+JustFilename(fname)
  197.     if exists(fname) then
  198.       send #Port, "The file "; fname; " already exists on disk."
  199.       exit sub
  200.     end if
  201.     send #Port, "Begin your "; ProtocolName(protocol); " upload of "; fname; " now"
  202.   else
  203.     fname = Setup.ulpath
  204.     send #Port, "Begin your "; ProtocolName(protocol); " upload of your file now"
  205.   end if
  206.   delay 1
  207.   receivefile fname, protocol
  208. end sub
  209.